/**
 * 注册：第二部
 */
var userUrl = rootPath + "/shequan";

$(function() {
		alert("userName:"+userName);
			initShequanType();
			initShequanList();
		});

// 初始化社圈类型下拉列表
function initShequanType() {
	var shequanType = $("#shequanType");
	var shequanTypeHtml = "";
	$.ajax({
				url : userUrl + "/types",
				type : "POST",
				dataType : "json",
				async : false,
				success : function(response) {
					if (response.success && response.busiSuccess) {
						var data = response.data;
						var shequanTypeData;
						for (var i = 0; i < data.length; i++) {
							shequanTypeData = data[i];
							shequanTypeHtml += "<option value="
									+ shequanTypeData.shequanTypeId + ">"
									+ shequanTypeData.shequanTypeName + "</option>";
						}
					} else {
						initDefailType();
					}
				},
				error : function(response) {
					initDefailType();
				}
			});
	function initDefailType() {
		shequanTypeHtml += "<option value=1>文艺类</option>";
	}
	shequanType.html(shequanTypeHtml);
}

// 初始化社圈列表
function initShequanList() {
	$.ajax({
				url : userUrl + "/shequan/all",
				type : "POST",
				dataType : "json",
				async : false,
				success : function(response) {
					if (response.success && response.busiSuccess) {
						var data = response.data;
//						var shequanData;
//						for (var i = 0; i < data.length; i++) {
//							shequanData = data[i];
//							
//						}
					} else {
						alert(response.message);
					}
				},
				error : function(response) {
					alert("连接服务器失败");
				}
			});

}